package com.jingdianjichi.auth.service.Impl;

import com.jingdianjichi.auth.bo.AuthRoleBO;
import com.jingdianjichi.auth.common.enums.IsDeletedFlagEnum;
import com.jingdianjichi.auth.convert.AuthRoleBOConverter;
import com.jingdianjichi.auth.entity.AuthRole;
import com.jingdianjichi.auth.service.AuthRoleDomainService;
import com.jingdianjichi.auth.service.AuthRoleService;
import com.jingdianjichi.auth.service.AuthUserRoleService;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Slf4j
public class AuthRoleDomainServiceImpl  implements AuthRoleDomainService {
    @Resource
    private AuthRoleService authRoleService;


    /**
     * 新增角色
     *
     * @param authRoleBO
     * @return
     */
    @Override
    public Boolean add(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleBOConverter.INSTANCE.convertBOToEntity(authRoleBO);
        authRole.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        Integer count = authRoleService.insert(authRole);
        return count >0;
    }

    /**
     * 修改角色
     *
     * @param authRoleBO
     * @return
     */
    @Override
    public Boolean update(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleBOConverter.INSTANCE.convertBOToEntity(authRoleBO);
        Integer count = authRoleService.update(authRole);
        return count>0;
    }

    /**
     * 删除角色
     *
     * @param authRoleBO
     * @return
     */
    @Override
    public Boolean delete(AuthRoleBO authRoleBO) {
        AuthRole authRole = AuthRoleBOConverter.INSTANCE.convertBOToEntity(authRoleBO);
        authRole.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
        Integer count = authRoleService.update(authRole);
        return count>0;
    }
}
